package com.otoe.dilidilivid.view.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.otoe.dilidilivid.adapter.ReviewAdapter;
import com.otoe.dilidilivid.R;
import com.otoe.dilidilivid.data.entity.Review;

import java.util.ArrayList;
import java.util.List;

public class ReviewActivity extends AppCompatActivity {

    List<Review> reviewList;
    RecyclerView recyclerView;
    ReviewAdapter reviewAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_review);

        EditText txt=(EditText) findViewById(R.id.ReviewTextView);
        recyclerView=(RecyclerView) findViewById(R.id.reviewRecycleView);
        reviewList=new ArrayList<>();
        reviewList.add(new Review("原始评论"));
        reviewAdapter=new ReviewAdapter(reviewList);
        recyclerView.setLayoutManager(new LinearLayoutManager(ReviewActivity.this,LinearLayoutManager.VERTICAL,false));
        recyclerView.setAdapter(reviewAdapter);

        findViewById(R.id.btnReview).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String text=txt.getText().toString();
                Log.e("文本",text);
                reviewAdapter.addItem(text);
                //清空输入框
                txt.setText("");
            }
        });
    }
}